<template>
    <div class="page">
        <mt-field label="昵称" is-link placeholder="请输入联系人" v-model="user.username"> </mt-field>
        <mt-button class="btn" type="primary" size="large" @click.stop="save">保存</mt-button>
        <mt-button class="btn" type="default" size="large" @click.stop="goBack">返回</mt-button>

    </div>
</template>


<script>
import CrossLine from "@/components/base/cross-line/cross-line";
import { mapGetters } from "vuex";
export default {
    components: {

        CrossLine
    },
    data() {
        return {
            user: { username: null }
        };
    },
    props: {},
    watch: {},
    methods: {
        goBack() {
            this.$router.back();
        },
        gotoEditUserInfo(type) {
            //   this.$router.push(`/order/list/${type}`);
        },
        gotoAddress() {
            //   this.$router.push(`/address`);
        },
        save() {
            this.user.id = this.userID;
            this.$$api_user_updateUser({
                data: this.user,
                fn: res => {
                    this.goBack();
                },
                errFn: res => {
                    console.log("api_user_updateUser errFn res2::", res);
                }
            });
        }
        ,
        _initUserData() {
            this.$$api_user_userInfo({
                data: this.userID,
                fn: res => {
                    this.user.username = res[0].username;
                }
            });
        }
    },
    filters: {},
    computed: {
        ...mapGetters(["userID"])
    },
    created() {
        this._initUserData(this.userID);
    },
    mounted() { },
    destroyed() { }
}
</script>

<style lang="scss" scoped>
@import "~@/assets/scss/base.scss";
@import "~@/assets/scss/const.scss";
@import "~@/assets/scss/mixin.scss";

.page {
    background-color: $app-background-color;
    padding: 0 15px;
    .btn {
        margin: 15px 0;
    }
}
</style>
